import Cookies from 'js-cookie'

const tokenExpires = function () {
    return new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
}
// token管理
export const authToken = {
    tokenKey: 'token',

    hasToken: function () {
        return Cookies.get(this.tokenKey)
    },

    setToken: function (token) {
        Cookies.set(this.tokenKey, token, {
            expires: tokenExpires()
        })
    },

    removeToken: function () {
        Cookies.remove(this.tokenKey)
    }
}
